<template>
  <div class="box">
    <p class="Count">男女比例人数</p>
    <p class="top-img"></p>
    <div class="sex">
      <div class="man">
        <img src="../../images//man.png" alt="" />
      </div>
      <div class="women">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>
    <div class="title">
      <p>男生45%</p>
      <p>女生55%</p>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
//引入Echarts
import * as echarts from "echarts";
let charts = ref();
onMounted(() => {
  let myCharts = echarts.init(charts.value);
  myCharts.setOption({
    //组件标题
    title: {
      text: "男女比例", //主标题
      textStyle: {
        //主标题颜色
        color: "skyblue",
      },
      left: "40%",
    },
    //x|y
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: "category",
    },
    series: [
      {
        type: "bar",
        data: [45],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: "skyblue",
          borderRadius: 20,
        },

        legendHoverLink: true,
      },
      {
        type: "bar",
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: "-100%",
        itemStyle: {
          color: "pink",
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  });
});
</script>

<style scoped lang="scss">
.box {
  background-color: #fff;
  background: url(../../images/dataScreen-main-lt.png) no-repeat;
  background-size: 100% 100%;
  margin-top: 10px;

  color: white;
  .top-img {
    margin-left: 20px;
    width: 67px;
    height: 7px;
    margin-top: 10px;
    background: url(../../images/dataScreen-title.png) no-repeat;
    background-size: 100% 100%;
  }
  .Count {
    margin-left: 20px;
    font-size: 20px;
  }
  .sex {
    display: flex;
    justify-content: space-evenly;
    margin-top: 30px;
    .man {
      width: 111px;
      height: 116px;
      background: url(../../images/man-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .women {
      width: 111px;
      height: 116px;
      background: url(../../images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .title {
    display: flex;
    margin-top: 10px;
    justify-content: space-evenly;
  }
  .charts {
    height: 100px;
  }
}
</style>
